Every topic is written in three layers, and you should read and revise in the same order:
- Definition box — the exact sentence to write first in the examination.
- Explanation in plain language — so that the idea actually makes sense, not just the words.
- Numbered points, tables and examples — this is where the marks are. Examiners award marks for points, not for paragraphs.
Boxes marked Exam tip tell you what is usually asked. Boxes marked Common mistake tell you what loses marks. Section 11 at the end lists practice questions grouped by mark weight.
This unit builds the vocabulary and the mental model for the whole course. Everything that follows — agent-based models in Unit II, parallel simulation in Unit III, statistics in Unit IV, and result analysis in Unit V — assumes that you can answer three questions about any simulation you meet: how does its clock advance, what kind of state does it carry, and how much of its output do we believe.
1. Systems, Models and Simulation
A system is a collection of interacting entities, with state, that we wish to study for some purpose.
A model is a simplified, purposeful representation of a system that preserves the features relevant to a stated question and deliberately discards the rest.
Simulation is the execution of a model over time on a computer in order to observe how the modelled system behaves, especially when analytical solution is impossible, too expensive, or too risky to obtain from the real system.
The order of those three words matters. We never simulate a system directly; we simulate a model of it. Every claim a simulation makes is therefore a claim about the model, and it transfers to the real world only as far as the model is valid. This single sentence is the reason validation (Unit V) exists as a topic at all.
1.1 Why simulate at all?
- The system does not exist yet. A new airport terminal, a new cache hierarchy, a new epidemic-control policy — you cannot measure what is not built.
- Experimenting on the real system is unsafe, unethical or illegal. You may not deliberately overload a live power grid or infect a population to test a policy.
- The analytical model is intractable. Queueing theory gives closed forms for a handful of idealised cases; real networks with priorities, blocking and correlated arrivals have none.
- Real experiments are too slow or too fast. Galaxy formation takes 109 years; a transistor switch takes 10−12 s. Simulated time can be compressed or dilated at will.
- We need many repetitions. Rare-event risk (a once-in-200-year flood) can be estimated by running the model ten million times.
- We need controllability and repeatability. A simulation can be re-run with exactly one parameter changed — something the real world never permits.
1.2 Classification of models
| Axis | Types | Meaning and example |
|---|---|---|
| Nature | Physical vs. mathematical | A wind-tunnel scale model vs. a set of equations. This course is entirely about mathematical (and hence computational) models. |
| Time | Static vs. dynamic | Static: a Monte Carlo estimate of π, no clock. Dynamic: a queue at a router evolving over time. |
| Randomness | Deterministic vs. stochastic | Deterministic: same input → same output, always. Stochastic: contains random variates, so output is itself a random variable and needs replication. |
| State change | Discrete vs. continuous | Discrete: number of jobs in a queue jumps by ±1. Continuous: tank level h(t) varies smoothly. See Section 3. |
| Clock | Time-stepped vs. event-driven | Fixed Δt advance vs. jump-to-next-event advance. See Section 2. |
| Space | Lumped vs. distributed | One temperature for a whole room vs. a temperature field T(x, y, t) solved on a mesh. |
Students routinely mix up discrete/continuous (a property of the state variables) with time-stepped/event-driven (a property of the clock mechanism). They are independent axes. A continuous model is almost always time-stepped, but a discrete-state model may be either. Write the two definitions apart and the marks are safe.
1.3 The simulation study life cycle
A simulation study is a research process, not a programming exercise. The standard sequence (Banks et al.) is:
- Problem formulation and objectives — write down the question the model must answer.
- Conceptual model building — entities, state, events, assumptions, level of detail.
- Data collection — arrival rates, service times, failure rates; fit distributions (Unit IV).
- Model translation — implement in a language or package.
- Verification — “Did I build the model right?” (code is faithful to the conceptual model).
- Validation — “Did I build the right model?” (model is faithful to reality). Covered fully in Unit V.
- Experimental design — run length, warm-up period, number of replications, scenarios.
- Production runs and statistical analysis of output.
- Documentation, reporting and implementation of the recommendation.
“Distinguish verification from validation” is a guaranteed short question. The one-line answer: verification checks the model against its specification; validation checks the model against reality. Then give one example of each.
2. Handling Stepped and Event-Based Time
A dynamic simulation needs a simulation clock: a variable holding the current value of simulated time, which is entirely separate from wall-clock time. There are exactly two ways to advance it.
2.1 Time-stepped (fixed-increment) simulation
In a time-stepped (fixed-increment, synchronous) simulation the clock advances by a constant step Δt, and at each tick every entity in the model is updated to reflect what happened during the interval [t, t+Δt ).
The main loop is trivially simple, which is exactly why it is used everywhere in physics, graphics and games:
t = 0
while t < T_end:
for each entity e: # order matters; see caution below
e.update(dt)
record_statistics(t)
t = t + dt
Choosing Δt is the whole art. Too large and events are missed or the numerical integration becomes unstable; too small and the run takes forever, most ticks doing nothing. A workable rule is Δt ≤ one-tenth of the fastest time constant in the system.
If entities are updated in place, in a loop, entity 5 sees entity 1's new state and entity 9's old state within the same tick. This asymmetry is a bug in most models (notably cellular automata, Unit II). The fix is double buffering: compute all new states from the old array, then swap. Always mention this when asked about pitfalls of time-stepped simulation.
2.2 Event-based (discrete-event) simulation
In an event-based or discrete-event simulation, state changes only at a countable set of instants called events. The clock jumps directly from the current event to the timestamp of the next event, so periods in which nothing happens consume no computation at all.
Three data structures define a DES engine:
- The simulation clock t.
- The state — queue lengths, server busy/idle flags, counters.
- The future event list (FEL) — a priority queue of (timestamp, event-type, entity) records ordered by timestamp.
schedule(first_arrival, t = 0)
while FEL not empty and t < T_end:
(t, event) = FEL.pop_min() # the clock JUMPS to t
handle(event) # may change state and schedule new events
accumulate_statistics()
Events: ARRIVAL and DEPARTURE.
- On
ARRIVAL: schedule the next arrival at t+Exp(λ). If the server is idle, mark it busy and scheduleDEPARTUREat t+Exp(μ); otherwise increment the queue length. - On
DEPARTURE: if the queue is non-empty, remove one customer and schedule the nextDEPARTURE; else mark the server idle.
Between 09:00 and 09:17 nothing happens, so a DES does zero work in that interval, while a 1 ms time-stepped model would execute 1 020 000 empty ticks.
Ties and determinism
Two events with identical timestamps must be broken deterministically (by a priority field, or by insertion sequence number), otherwise the same seed gives different answers on different runs or machines — a reproducibility failure that is very hard to debug later.
2.3 Comparison and choice
| Criterion | Time-stepped | Event-based |
|---|---|---|
| Clock advance | Fixed Δt | Variable; jumps to next event time |
| Cost driver | Number of ticks × number of entities | Number of events (independent of idle time) |
| Accuracy of timing | Quantised to Δt; events inside a step are aliased | Exact to floating-point precision |
| Core data structure | Array / grid / state vector | Priority queue (heap, calendar queue) |
| Implementation effort | Low — a for-loop | Higher — event scheduling discipline required |
| Parallelisation | Straightforward: barrier per tick (Unit III) | Hard: needs conservative or optimistic synchronisation (Unit III) |
| Best when | State changes continuously and everywhere (fluids, fields, ODEs, games) | Activity is sparse and bursty (queues, networks, logistics, hardware) |
A very common 10-mark question: “Compare stepped and event-based time handling with an example.” Structure: two definitions → two pseudocode loops → the table above (six rows is plenty) → one worked example showing wasted ticks → one sentence on when a hybrid is used. That is a full-mark answer.
2.4 Mixed and adaptive time advance
Real engines often combine the two. A network simulator may integrate a physical-layer signal with a fixed step while handling packet arrivals as events; a game engine uses a fixed step for physics but an event queue for collisions and AI triggers. Adaptive time-stepping (Section 4.4) sits in between: the step shrinks where the solution changes fast and grows where it is smooth.
3. Discrete versus Continuous Modelling
In a discrete model the state variables change only at separated points in time, by finite jumps; the state space is typically countable (queue length, number of infected people, machine up/down).
In a continuous model the state variables change smoothly with time and are usually described by differential equations; the state space is a continuum (temperature, concentration, velocity, voltage).
3.1 The same system, modelled both ways
Population growth is the standard classroom pair, and is also Experiment 2 in your laboratory.
These are not the same model. The continuous logistic equation always converges monotonically to the carrying capacity K. Its discrete counterpart, for growth rates above roughly r = 2, oscillates; above about 2.57 it becomes chaotic. Discretising a continuous model can therefore introduce behaviour that the original system does not have — a point worth one full paragraph in any answer on this topic.
3.2 Choosing between them
- Population size. With 20 machines, integrality matters (you cannot have 3.7 machines) → discrete. With 109 molecules, the fluid limit is excellent → continuous.
- Question asked. If the answer is a mean flow rate, continuous suffices. If the answer is “what fraction of customers wait more than 5 minutes”, individual identity is needed → discrete.
- Availability of data. Rate constants favour ODEs; logged timestamps favour discrete-event models.
- Cost. Continuous models scale with the number of state variables; discrete models scale with the number of entities and events.
| Aspect | Discrete | Continuous |
|---|---|---|
| State change | Jumps at event instants | Smooth, at all instants |
| Mathematics | Difference equations, Markov chains, queueing | ODEs, PDEs, SDEs |
| Typical solver | Event list / state machine | Euler, Runge–Kutta, finite difference/element |
| Individuality | Entities are tracked individually | Only aggregate quantities exist |
| Error concern | Statistical (sampling) error | Truncation and round-off error |
| Examples | Bank queue, packet network, assembly line, SIR on a contact network | Heat conduction, orbital motion, chemical kinetics, compartmental SIR |
3.3 Combined (continuous–discrete) simulation
Many engineering systems are genuinely both. A chemical batch reactor has continuous temperature and concentration, but a discrete valve that opens when concentration crosses a threshold. Such models are called combined or hybrid (Section 7). The technical difficulty is state-event detection: the exact instant of threshold crossing lies inside an integration step, so the solver must detect the sign change of a zero-crossing function and then bisect or interpolate back to locate the crossing time before firing the discrete event.
4. Numerical Techniques
Continuous models must be discretised before a computer can execute them. The numerical method chosen determines the accuracy, the stability and much of the cost of the whole simulation.
4.1 Numerical integration of ODEs
Given the initial value problem dy/dt = f(t, y) with y(t0) = y0, and step h:
with k1 = f(tn, y n), k2 = f(tn + h/2, yn + hk1/2), k3 = f(tn + h/2, yn + hk2/2), k4 = f(tn + h, yn + hk3).
Integrate dy/dt = −y, y(0) = 1 to t = 1 (exact value e−1 = 0.367879). With h = 0.1, explicit Euler gives 0.910 = 0.348678 (error 1.9×10−2); RK4 with the same step gives 0.367879 (error < 10−7). Halving h halves Euler's error but divides RK4's by sixteen — that is what “fourth order” means in practice.
4.2 Stability and stiffness
Accuracy is not the only concern; a method can be accurate in principle and still explode. For the test equation dy/dt = λy with λ < 0, explicit Euler is stable only if |1 + hλ| < 1, that is h < 2/|λ|. Backward Euler is stable for every h > 0 (it is A-stable), which is why implicit methods are used for stiff systems — systems containing time constants that differ by many orders of magnitude, where an explicit method would be forced down to the smallest constant even though the interesting behaviour is slow.
4.3 Other numerical machinery you will meet
- Root finding — bisection, Newton–Raphson; used for state-event detection and for solving the implicit step of an implicit integrator.
- Linear algebra — LU, Gauss–Seidel, conjugate gradient; the inner loop of every mesh-based simulation (Unit II).
- Interpolation and quadrature — reconstructing values between grid points, computing integrals of the output.
- Finite difference / finite element / finite volume — discretisation of PDEs in space, giving the huge sparse systems that motivate Unit III.
4.4 Adaptive step control
Embedded pairs such as Runge–Kutta–Fehlberg (RKF45) compute two estimates of different order at each step; their difference estimates the local error, and the step is accepted, rejected or resized to keep that error near a tolerance. This gives accuracy where the solution is fast-changing and speed where it is not.
“RK4 is always better than Euler” is false as stated. RK4 costs four function evaluations per step. If f is expensive and the tolerance is loose, Euler with a smaller step can win; and for a stiff problem, neither explicit method works — you need an implicit one. Answer such questions in terms of accuracy per unit cost and stability, not in terms of a ranking.
5. Sources and Propagation of Error
Absolute error = |computed − true|. Relative error = |computed − true| / |true|. In simulation the “true” value may itself be unknown, so error is estimated by refinement studies, by analytical special cases, or by statistical confidence intervals.
5.1 The five sources of error
- Modelling error. The gap between reality and the conceptual model — assumptions of independence, neglected friction, homogeneous mixing. Usually the largest error, and the one no numerical refinement can reduce.
- Data / input error. Measurement noise, wrongly fitted distributions, outdated parameters.
- Truncation (discretisation) error. From replacing a limit with a finite quantity: a derivative by a difference quotient, an infinite series by a partial sum, continuous time by a step h.
- Round-off error. From finite floating-point precision (IEEE 754 double: about 16 significant decimal digits, machine epsilon ≈ 2.2×10−16).
- Statistical (sampling) error. In stochastic models, from using a finite number of replications; decreases only as 1/√n (Unit IV).
Truncation error decreases as the step h shrinks, while accumulated round-off error increases because more steps are taken. Their sum has a minimum: there is an optimal h, and going below it makes the answer worse. Sketching this U-shaped curve earns marks.
5.2 Propagation of error
Errors do not stay where they are born. For a smooth function y = f(x 1, …, xn) with small independent input errors, first-order propagation gives:
The partial derivatives are exactly the sensitivity coefficients of Unit IV, so error propagation and sensitivity analysis are two views of the same computation.
Conditioning and stability
- A problem is ill-conditioned if small input changes cause large output changes; the condition number measures this. No algorithm can rescue an ill-conditioned problem.
- An algorithm is unstable if it amplifies round-off that a better algorithm would not. This can be fixed by choosing a different method.
- In chaotic systems (Lorenz, n-body, weather) errors grow exponentially: e(t) ≈ e0eλt with λ the largest Lyapunov exponent. Long-run trajectories are then meaningless individually, and only statistical properties of the attractor are predictable.
5.3 Practical rules for controlling error
- Never test floating-point numbers for equality; compare against a tolerance.
- Avoid subtracting nearly equal numbers (catastrophic cancellation); rearrange the formula algebraically. The classic fix is the stable quadratic-root formula.
- Sum many small numbers in ascending order, or use Kahan compensated summation.
- Do a grid-refinement (convergence) study: halve h, and confirm that the answer changes by the amount the method's order predicts.
- Report a confidence interval, never a bare number, for stochastic output.
- Keep a fixed random seed for debugging and vary it for production replications.
6. Stochastic Modelling and Simulation
A stochastic simulation is one in which at least one input is a random variable, so that each run produces a different sample path and the output is itself a random variable. A single run is therefore one observation, never an answer.
6.1 Why randomness belongs in the model
Uncertainty is not an imperfection to be averaged away at the input. Because most performance measures are non-linear, the mean of the outputs is not the output of the mean — the “flaw of averages”. A road designed for the average traffic load is congested half the time; a server sized for mean demand has unbounded queues at the peak.
6.2 The machinery (previewed here, detailed in Unit IV)
- Pseudo-random number generators (PRNGs) produce a deterministic stream u1, u2, … that behaves statistically like independent Uniform(0,1) draws. Modern choices: Mersenne Twister, PCG, xoshiro256++. Requirements: long period, good equidistribution, speed, and reproducibility from a seed.
- Random variate generation converts uniforms into the required distribution — inverse transform, acceptance–rejection, convolution, composition.
- Replication: run n independent repetitions with different substreams and report the mean with a confidence interval.
- Variance reduction: common random numbers, antithetic variates, control variates, importance sampling — techniques that buy accuracy without buying CPU time.
The 1/√n law is worth memorising: to halve the confidence interval you must quadruple the number of replications. This is the single most important economic fact about stochastic simulation, and it is the reason Unit III (parallelism) and variance reduction both matter.
6.3 Common stochastic model families
- Markov chains — discrete or continuous time, memoryless transitions.
- Poisson processes — the standard model of “random arrivals” with rate λ; inter-arrival times are Exponential(λ).
- Random walks and Brownian motion — diffusion, stock prices.
- Stochastic differential equations — dX = μdt + σdW, solved by the Euler–Maruyama scheme.
- Monte Carlo methods — estimation of integrals, probabilities and rare events by sampling (Unit II, Section on Monte Carlo).
If a question asks “why must a stochastic simulation be replicated?”, the marks are for: (i) output is a random variable; (ii) one run gives one sample, with unknown variance; (iii) confidence interval formula; (iv) 1/√n convergence; (v) different seeds / independent substreams must be used.
7. Optimization in Simulation Models
Simulation optimization is the problem of finding the input configuration x* that optimises the expected performance of a simulation model, minx∈X E[g(x, ξ)], where the objective can only be estimated by running the (noisy, expensive, derivative-free) model.
Three properties make this hard and distinguish it from ordinary mathematical programming:
- The objective is a black box — no formula, hence no gradient.
- Each evaluation is noisy — two evaluations of the same x differ.
- Each evaluation is expensive — minutes to hours, so the budget is a few hundred evaluations, not millions.
7.1 Families of methods
| Family | Representative methods | When to use |
|---|---|---|
| Ranking & selection | Two-stage Rinott, KN procedure, OCBA | Few discrete alternatives (say ≤ 100); allocate replications to find the best with a guaranteed probability of correct selection. |
| Gradient-based | Finite differences, SPSA, infinitesimal perturbation analysis, likelihood ratio | Continuous parameters, smooth response; SPSA needs only 2 evaluations per iteration regardless of dimension. |
| Metaheuristics | Genetic algorithms, simulated annealing, tabu search, particle swarm, ant colony | Large, rugged, combinatorial search spaces; no guarantee of optimality but good solutions in practice. This is what commercial packages (OptQuest) use. |
| Metamodel / surrogate | Response surface methodology, kriging, Bayesian optimization | Very expensive simulations; fit a cheap surrogate to a designed set of runs and optimise that, adding new runs where the surrogate is uncertain. |
| Sample average approximation | Fix the seed, optimise the deterministic surrogate problem | When the model can be re-expressed as a mathematical program for a fixed sample. |
7.2 Design of experiments as the cheap alternative
Before optimising, screen. A 2k factorial or fractional-factorial design identifies which of k factors actually matter, at a fraction of the cost of a full grid search. Latin hypercube sampling covers a continuous space evenly with few runs. Optimisation is then carried out only over the two or three factors that survived screening.
Comparing two designs using one replication each and declaring the smaller number the winner. With noisy output the difference may be pure sampling variation. Always compare with a paired confidence interval on the difference, ideally using common random numbers so that both designs face the same random events.
8. Hybrid and Multi-Scale Modelling
A hybrid model combines two or more modelling paradigms — for example continuous (system dynamics), discrete-event and agent-based — within a single executable model, so that each part of the system is represented in the formalism that suits it best.
A multi-scale model couples sub-models that operate at different characteristic length or time scales, passing information between the scales.
8.1 Why hybridise
- No single paradigm fits a whole real system: a hospital has continuous disease progression, discrete patient flow through resources, and autonomous decision-making staff.
- Detail is needed only in part of the domain; the rest can run in a cheaper representation.
- Legacy models already exist in different formalisms and must be federated rather than rewritten (see HLA, Section 9).
8.2 Coupling patterns
- Hierarchical (scale-bridging). A fine-scale model supplies parameters to a coarse-scale one — molecular dynamics giving a viscosity to a fluid solver.
- Concurrent (domain decomposition). Different regions use different models at the same time, exchanging boundary data — atomistic near a crack tip, continuum elsewhere.
- Sequential / one-way. Output of model A becomes input of model B (weather → crop yield).
- Feedback / two-way. Both models influence each other every coupling interval; needs a consistent coupling time step and often iteration to convergence.
8.3 The hard problems in coupling
- Time-scale mismatch. One model steps in nanoseconds, the other in hours; the coupling interval and the sub-cycling scheme must be chosen explicitly.
- Unit, semantic and representation mismatch. Converting a continuous concentration into an integer number of agents (and back) is not neutral — rounding systematically biases small populations.
- Consistency and conservation. Mass, energy or entity count must not be created or destroyed at the interface.
- Stability of the coupled system. Two individually stable solvers can be unstable when coupled explicitly.
- Compounded validation. Each sub-model and every interface must be validated; the credibility of the whole is bounded by the weakest link.
National-level transmission is modelled with continuous SIR compartments (fast, aggregate). Within a chosen city, individuals are modelled as agents on a contact network (Unit II) to test contact-tracing policies. The compartment model exports an imported-case rate into the city model; the city model exports a measured effective reproduction number back. Both run on the same coupling interval of one day.
9. Modelling and Simulation Standards
Standards exist so that models built by different teams, in different tools, at different times can be trusted, reused and connected. They fall into three groups.
9.1 Interoperability standards
- HLA — High Level Architecture (IEEE 1516). The dominant standard for distributed simulation. A federation of federates communicates through a Run-Time Infrastructure (RTI) using a shared Federation Object Model. The RTI provides six service groups, of which time management (ensuring events are delivered in timestamp order) and data distribution management are the ones to name in an answer.
- DIS — Distributed Interactive Simulation (IEEE 1278). Older, packet-based (protocol data units), used for real-time platform-level military training.
- FMI — Functional Mock-up Interface. A tool-independent standard for exchanging and co-simulating dynamic models as Functional Mock-up Units; the norm in automotive and control engineering.
- TENA and DDS — test-range and publish/subscribe middleware used where real hardware is in the loop.
9.2 Process and credibility standards
- DSEEP (IEEE 1730) — Distributed Simulation Engineering and Execution Process: the recommended life cycle for building a federation.
- VV&A — Verification, Validation and Accreditation (IEEE 1516.4, US DoD guidance): a formal, auditable process ending in a decision that a model is fit for a stated purpose.
- ASME V&V 10 / 20 — verification and validation in computational solid mechanics and fluid dynamics.
- SISO product standards, e.g. SRML, MSDL, C-BML, for scenario and behaviour exchange.
9.3 Model representation and reporting standards
- DEVS (Discrete Event System Specification) — a formal, mathematically defined modelling formalism with atomic and coupled models; the reference semantics for discrete event simulation and a common target for model exchange.
- SBML / CellML / NeuroML — domain markup languages for systems biology, physiology and neuroscience.
- SED-ML — describes the experiment (which model, which solver, which outputs), so that a published result can be reproduced.
- ODD protocol (Overview, Design concepts, Details) — the accepted template for describing an agent-based model in a paper so that others can reimplement it.
- SysML / Modelica — standardised languages for system architecture and for equation-based physical modelling.
For “write short notes on M&S standards”, do not list twenty acronyms. Give the three categories above, then two or three examples in each with one line of purpose, and close with why standards matter: interoperability, reuse, credibility, reproducibility and procurement.
10. Simulation Software and Tools
This course is about building simulation environments, not merely operating a package — so you should be able to justify the choice between writing a simulator and buying one.
| Category | Examples | Character |
|---|---|---|
| General-purpose languages + libraries | Python (SimPy, NumPy/SciPy, Mesa, NetworkX, salabim), C++ (with a hand-written event list), Julia (DifferentialEquations.jl, Agents.jl), R | Maximum flexibility and transparency; you own the algorithms. Chosen for research and for this course's laboratory. |
| Discrete-event packages | Arena, Simul8, FlexSim, AnyLogic, ExtendSim, GPSS | Drag-and-drop process blocks, animation, built-in statistics and optimiser. Fast for standard queueing/manufacturing studies. |
| Continuous / equation-based | MATLAB & Simulink, Modelica/OpenModelica, Dymola, Scilab/Xcos | Block diagrams and acausal equations; strong ODE/DAE solvers and control design. |
| Agent-based / complex systems | NetLogo, Repast, MASON, GAMA, Mesa | Grids, networks, spatial agents, visual inspection of emergent behaviour (Unit II). |
| Domain-specific | ns-3 / OMNeT++ (networks), gem5 (computer architecture), SUMO / VISSIM (traffic), OpenFOAM / ANSYS (CFD), LAMMPS / GROMACS (molecular), PowerFactory / PSS®E (power) | Validated domain physics and model libraries; the sensible choice when your problem is already in a well-served domain. |
| Parallel / HPC frameworks | MPI, OpenMP, CUDA, ROSS, Charm++, Dask, Ray | The substrate for Unit III; execution machinery rather than modelling formalism. |
| Analysis and visualisation | Matplotlib, Plotly/Dash, ParaView, VisIt, Tableau, D3.js | Unit V: turning result files into defensible figures and interactive interfaces. |
10.1 Criteria for selecting a tool
- Does its world view (process interaction, event scheduling, activity scanning, agent-based, equation-based) match your model?
- Statistical support: distribution fitting, replication control, confidence intervals, variance reduction.
- Scalability and parallel execution; ability to run headless in batch on a cluster.
- Extensibility: can you insert custom code, or are you trapped inside the GUI?
- Verification and debugging support: tracing, step-through, event logs, seed control.
- Interoperability: HLA/FMI support, standard input and output formats.
- Licence cost, licence terms, and the size of the user community; longevity of the vendor.
- Reproducibility: version pinning, scripted (not click-driven) experiments.
import simpy, random
def customer(env, name, server):
with server.request() as req: # join the queue
yield req # wait for the server
yield env.timeout(random.expovariate(1/3.0)) # service
def source(env, server):
i = 0
while True:
yield env.timeout(random.expovariate(1/4.0)) # inter-arrival
env.process(customer(env, i, server)); i += 1
env = simpy.Environment()
server = simpy.Resource(env, capacity=1)
env.process(source(env, server))
env.run(until=1000)
Notice that the future event list, the clock and the ordering are all provided by the framework; what you write is only the process description. That is the process-interaction world view.
11. Ethical and Practical Considerations
Simulation results are used to justify decisions that affect money, safety and lives. The ethical obligations are therefore professional obligations, not optional extras.
11.1 Ethical issues
- Honest reporting of assumptions and limitations. Every model is wrong in stated ways; concealing the assumptions makes a result rhetorical rather than scientific.
- Fitness for purpose. A model validated for one operating range must not be quoted outside it. Accreditation exists precisely to record the domain of validity.
- Avoiding advocacy modelling. Choosing parameters, scenarios or output measures that produce a pre-determined conclusion is falsification, however subtly done.
- Transparency and reproducibility. Publish the model, the parameters, the seeds and the version. An unpublishable model cannot be checked and should not be believed.
- Data privacy and consent. Agent-based models of health, mobility or social behaviour are often built from personal data; anonymisation, aggregation, consent and applicable data-protection law all apply.
- Bias and fairness. A model calibrated on data from one group and applied to another can systematically disadvantage people — in policing, credit, healthcare or infrastructure planning.
- Communication to non-experts. Presenting a stochastic projection as a prediction, or hiding uncertainty behind a single smooth curve, misleads the decision maker even when every number is correct.
- Dual use and misuse. Models of infrastructure, epidemics or weapons can be used to attack as well as to protect; access and publication need judgement.
- Professional codes. The ACM/IEEE Software Engineering Code of Ethics and the SCS/SISO codes for simulationists apply to this work directly.
11.2 Practical considerations
- Data quality and availability usually limits accuracy far more than the algorithm does. Budget most of the project time for data.
- The right level of detail. Detail costs data, runtime and credibility. A model should be as simple as the question permits — and no simpler.
- Computational budget. Run length, warm-up, replications and scenario count multiply; plan them before running anything.
- Software engineering discipline. Version control, unit tests on the event logic, regression tests on known analytical cases, and a recorded seed for every reported figure.
- Documentation. The model description (ODD or equivalent) must let a competent stranger reimplement the model.
- Stakeholder involvement. A model that domain experts have not reviewed will not be trusted, and usually should not be.
“All models are wrong, but some are useful” (George Box) is the standard opening quotation for an ethics answer — but do not stop there. Follow it with the point that usefulness is relative to a stated purpose, and that stating the purpose, the assumptions and the uncertainty is the modeller's ethical duty.
12. Unit Summary
- A simulation executes a model, not the system; its authority is bounded by validation.
- Two clock mechanisms exist: time-stepped (fixed Δt, simple, wasteful when idle) and event-based (jumps to the next event, exact timing, needs a future event list).
- State is either discrete (jumps, countable, individual entities) or continuous (smooth, differential equations, aggregates); combined models need state-event detection.
- Numerical methods trade accuracy against cost and stability: Euler O(h), trapezoidal O(h2), RK4 O(h4); stiff problems require implicit methods.
- Five error sources: modelling, data, truncation, round-off, statistical. Truncation falls and round-off rises as h shrinks, so an optimal step exists.
- Stochastic models give random output: replicate, report confidence intervals, remember the 1/√n law, and use variance reduction.
- Simulation optimization deals with a noisy, expensive, gradient-free objective: ranking and selection, metaheuristics, and surrogate/metamodel methods.
- Hybrid and multi-scale models couple paradigms and scales; the difficulty lies in the interfaces.
- Standards (HLA, FMI, DEVS, DSEEP, VV&A, ODD) provide interoperability, credibility and reproducibility.
- Ethical practice = honest assumptions, stated domain of validity, published data and seeds, uncertainty communicated, privacy respected.
12.1 Key terms
System · model · simulation · simulation clock · time-stepped · discrete-event · future event list · state event · truncation error · round-off error · stiffness · A-stability · PRNG · replication · confidence interval · variance reduction · metamodel · ranking and selection · federation / federate / RTI · DEVS · VV&A · ODD protocol.
12.2 Practice questions
Short answer (2–3 marks each)
- Define simulation. State two situations in which simulation is preferred to analytical solution.
- Differentiate between verification and validation with one example of each.
- What is a future event list and why must it be a priority queue?
- Distinguish truncation error from round-off error.
- Why does halving the confidence-interval width require four times as many replications?
- What is a stiff system, and which class of integrators is used for it?
- State any three purposes served by simulation standards.
Medium answer (5 marks each)
- Write the algorithm for a time-stepped simulation and for an event-driven simulation, and state two advantages of each.
- Explain the sources of error in a simulation study and sketch how total error varies with the step size h.
- Explain, with the M/M/1 queue as an example, how a discrete-event simulation advances time and accumulates statistics.
- Discuss the difficulties specific to simulation optimization and name one method from each of three families.
- What is multi-scale modelling? Describe two coupling patterns and two problems that arise at the interface.
Long answer (10 marks each)
- Compare stepped and event-based time handling in simulations under at least six criteria, with pseudocode and one worked example showing the cost difference.
- Compare discrete and continuous modelling. Illustrate with a population-growth model formulated both ways, and explain how the discretisation can introduce behaviour absent from the continuous model.
- Describe the numerical techniques used in continuous simulation. Derive or state Euler and RK4, discuss order of accuracy, stability, stiffness and adaptive step control.
- Explain stochastic simulation end to end: pseudo-random generation, variate generation, replication, confidence intervals and variance reduction.
- Discuss the ethical and practical considerations in modelling and simulation, with examples of how each can be violated in practice.
12.3 Further reading
- J. Banks (ed.), Handbook of Simulation: Principles, Methodology, Advances, Applications and Practice, Wiley — chapters 1–3.
- A. M. Law, Simulation Modeling and Analysis — the standard reference for the study life cycle, input modelling and output analysis.
- S. Asmussen and P. W. Glynn, Stochastic Simulation: Algorithms and Analysis, Springer — for Sections 6 and 7.
- B. P. Zeigler et al., Theory of Modeling and Simulation — for DEVS and the formal treatment of time.
- K. Al-Begain and A. Bargiela (eds.), Seminal Contributions to Modelling and Simulation, Springer.